package com.sff.site.tree {
	import com.sff.core.sff_internal;
	import com.sff.site.abstract.AbstractPath;
	import com.sff.site.core.INode;
	import com.sff.site.core.IPath;
	
	import flash.external.ExternalInterface;
	import flash.net.URLVariables;

	public class SiteTreePath extends AbstractPath implements IPath {

		public function SiteTreePath( path : String, device : String = null, params : URLVariables = null ) {
			super( path , device, params );			
		}
		
		public function activate( params : URLVariables = null ) : void {
			if( params ) {
				setParams( params );
			}
			
			TreesProvider.sff_internal::getTree( _device ).activePath = this;
		}
		
		override public function cleanup() : IPath {
			var p : String = "";
			var ns : Array = nodes( );
			for (var i : int = 1; i < ns.length; i++) {
				p += AbstractPath.SEPARATOR + ns[i].getId();
			}
			return new SiteTreePath( p, _device, _params );
		}

		override public function append( path : String) : IPath {
			path = path.replace( STRIP_PATH, "$2" );
			return new SiteTreePath( _path+"/" + path, _device, _params );			
		}

		override protected function _getRootNode() : INode {
			return TreesProvider.sff_internal::getTree( _device ).root;
		}

	}
}

